/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aicue1.services;

import aicue1.beans.Customer;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;

/**
 *
 * @author Thomas
 */
public class BankingServiceImpl implements BankingService, CallbackHandler
{

    public void charge_credit_card(Customer customer, BigDecimal amount)
    {
        System.out.println("\n[BankingService] " + new Date() + "\n\tCharging credit card from customer with ID " + customer.getId());
        System.out.println("[BankingService] Success :: true");
    }

    public void do_bank_transfer(Customer customer, BigDecimal amount)
    {
        System.out.println("\n[BankingService] " + new Date() + "\n\tDoing bank transfer for customer with ID " + customer.getId());
        System.out.println("[BankingService] Success :: true");
    }

    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
    {
        WSPasswordCallback pwdCallback = (WSPasswordCallback)callbacks[0];

        if (pwdCallback.getIdentifier().equals("bookstoreclient"))
            pwdCallback.setPassword("b00k5t0r3");
    }
}